# Maintainer: Jaroslav Lichtblau <svetlemodry@archlinux.org>
# Contributor: Eric Belanger <eric@archlinux.org>
# Contributor: Angelo Theodorou <encelo@users.sourceforge.net>
# Contributor: Alexander Rødseth <rodseth@gmail.com>

pkgname=ffmpeg2theora
pkgver=0.30
pkgrel=8
pkgdesc="Simple converter to create Ogg Theora files"
arch=('loong64' 'x86_64')
url="https://www.v2v.cc/~j/ffmpeg2theora/"
license=('GPL')
depends=('ffmpeg4.4' 'libkate')
makedepends=('scons' 'git')
source=(http://v2v.cc/~j/ffmpeg2theora/downloads/$pkgname-$pkgver.tar.bz2
        ffmpeg2theora-0.29-underlinking.patch scons-python3.patch)
sha256sums=('4f6464b444acab5d778e0a3359d836e0867a3dcec4ad8f1cdcf87cb711ccc6df'
            '3b937c7e3a5afe327ee75e246ef606a747b8fb5880b43a864b3b9db4a245ef7f'
            '1ebf868692ef2efdb4b30fbefba34cfcd2562dbce7b2acecef15d837fd7b1e6a')

prepare() {
  cd "${srcdir}"/$pkgname-$pkgver

  echo "#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000" >> src/ffmpeg2theora.h
  patch -p0 -i ../ffmpeg2theora-0.29-underlinking.patch
  patch -p1 -i ../scons-python3.patch
}

build() {
  cd "${srcdir}"/$pkgname-$pkgver

  export PKG_CONFIG_PATH='/usr/lib/ffmpeg4.4/pkgconfig'
  scons
}

package() {
  cd "${srcdir}"/$pkgname-$pkgver

  scons install destdir="${pkgdir}" prefix="/usr" mandir="PREFIX/share/man"
}
